***************************************************************** * TEASER GS Source Code * * By Timothy // Shay ORCA/M GS Assembler * * Copyright 1991 By MindCraft Publ. Corp. Lincoln, MA 01773 * ***************************************************************** KEEP TEASER MAIN START PHK ;Environment: Data Bank PLB ;equals Code Bank ***************************************************************** * Start up all the necessary tools * ***************************************************************** WAKEUP LDX #$0201 ;Start Tool Locator JSL $E10000 ;TLStartup PEA 0 ;Start Memory Manager LDX #$0202 ;MMStartup JSL $E10000 JSR ERRORS ;Check for errors PLA ;Keep our UserID STA USERID LDX #$0203 ;Start Misc Tools JSL $E10000 ;MTStartup JSR ERRORS ;Check for errors PEA 0 ;Get direct pages PEA 0 ;for toolbox use PEA 0 ;Space for handle PEA $500 ;5 pages LDA USERID ;Our ID PHA PEA $C005 ;Locked, fixed, aligned, PEA 0 ;fixed address in PEA 0 ;Bank 00 LDX #$0902 JSL $E10000 ;NewHandle JSR ERRORS ;Check for errors PLA ;De-reference our handle STA 0 STA HANDLE PLA STA 2 STA HANDLE+2 LDA [0] ;Get our direct page STA DPAGES ;address and keep it LDA DPAGES ;Start Quickdraw PHA ;DP address PEA 0 ;320 mode PEA 0 ;Default pixel map size LDA USERID ;Our ID PHA LDX #$0204 JSL $E10000 ;QDStartup JSR ERRORS ;Check for errors LDA DPAGES ;Start Event Manager CLC ADC #$300 PHA ;DP address PEA 20 ;Event queue size PEA 0 ;Minimum X for mouse PEA 320 ;Maximum X for mouse PEA 0 ;Minimum Y for mouse PEA 200 ;Maximum Y for mouse LDA USERID PHA ;Our ID LDX #$0206 JSL $E10000 ;EMStartup JSR ERRORS ;Check for errors TOOLOAD PEA $1B ;Load Font Manager PEA 0 ;Any version LDX #$0F01 JSL $E10000 ;LoadOneTool JSR ERRORS ;Check for errors CMP #$DE01 ;Recoverable disk error? BEQ TOOLOAD ;Yes, try loading again CMP #$DE00 ;Non-recoverable error? BNE FMSTART ;No, continue JMP FIN1 ;Yes, we're through FMSTART LDA USERID ;Start Font Manager PHA ;Our ID LDA DPAGES CLC ADC #$400 PHA ;DP address LDX #$021B JSL $E10000 ;FMStartup JSR ERRORS ;Check for errors ***************************************************************** * Get Ready - Initialize game screen and variables * ***************************************************************** BEGIN PEA $EEEE ;Clear screen to LDX #$1504 ;light grey JSL $E10000 ;ClearScreen LDA #HIMSG ;Send 'Hello' message JSR MSG JSR GETMK ;Get any event PEA 0 ;Change color table 0 PEA COLORS|-16 ;to our color table PEA COLORS LDX #$0E04 JSL $E10000 ;SetColorTable BEGIN1 PEA 0 ;Clear screen to black LDX #$1504 JSL $E10000 ;ClearScreen LDX #$CA04 ;Show the mouse JSL $E10000 ;InitCursor PEA 14 ;Pen = light grey LDX #$3704 JSL $E10000 ;SetSolidPenPat PEA TOPREC|-16 ;Draw title box PEA TOPREC LDX #$5404 JSL $E10000 ;PaintRect PEA MIDREC|-16 ;Draw game box PEA MIDREC LDX #$5404 JSL $E10000 ;PaintRect PEA BTMREC|-16 ;Draw Q-R box PEA BTMREC LDX #$5404 JSL $E10000 ;PaintRect PEA 0 ;Pen = black LDX #$3704 JSL $E10000 ;SetSolidPenPat PEA QREC|-16 ;Draw Quit box PEA QREC LDX #$5304 JSL $E10000 ;FrameRect PEA RREC|-16 ;Draw Restart box PEA RREC LDX #$5304 JSL $E10000 ;FrameRect LDA #GAMMSG ;Send game message JSR MSG LDA #$1FF ;Old field = all stars STA OLDPIC BEGIN2 STZ MOVES ;Restart Reenters here LDA #0 ;New field = all holes JSR FIXPIC ;Draw game field LDA #16 ;New field = start JSR FIXPIC ;Draw game field ***************************************************************** * Start Playing! - This is the main 'thinking' loop * ***************************************************************** THINK JSR GETMK ;Get an event BCS THINK ;Not valid, get another CMP #18 ;Quit? BNE THINK1 JMP FIN THINK1 CMP #20 ;Restart? BEQ BEGIN2 LDY BXPTR ;Get the field bit for LDA STRPTS,Y ;our chosen system AND OLDPIC ;Check for a hit BNE THINK2 JSR BLOOP ;Miss, bloop and get BRA THINK ;another event THINK2 JSR BLEEP ;Hit, bleep INC MOVES ;Add to move count LDY BXPTR ;Make the changes to the LDA OLDPIC ;game field EOR HITMODS,Y JSR FIXPIC ;Draw game field LDA OLDPIC ;Check for a winning or BEQ WL ;losing field CMP #$1EF BNE THINK ***************************************************************** * Win/Lose Routines * ***************************************************************** WL JSR BLEEP ;Win or lose - bleep and PEA 9 ;flash the game board WL1 LDY #$FFFF ;several times with a WL2 DEY ;short pause between BNE WL2 ;flashes PLY DEY BEQ WL3 PHY PEA MIDREC|-16 ;Invert game box PEA MIDREC LDX #$5604 JSL $E10000 ;InvertRect BRA WL1 WL3 JSR BLEEP ;Bleep again and PEA 14 ;Pen = light grey LDX #$3704 JSL $E10000 ;SetSolidPenPat PEA MIDREC|-16 ;Fill the game box PEA MIDREC ;with light grey LDX #$5404 JSL $E10000 ;PaintRect LDA OLDPIC BEQ LOSE WIN LDA #WINMSG ;Send the winning or BRA WL4 LOSE LDA #LOSEMSG ;losing message WL4 JSR MSG WL5 JSR GETMK ;Get an event CMP #20 ;Restart? BNE WL6 JMP BEGIN1 WL6 CMP #18 ;Quit? BNE WL5 JMP FIN ***************************************************************** * Get mouse/keyboard events and evaluate them * ***************************************************************** GETMK PHA ;Get an event PEA $FFFF ;All events PEA EVREC|-16 ;Location of event record PEA EVREC LDX #$0A06 JSL $E10000 ;GetNextEvent PLA BEQ GETMK LDA EVWHAT ;Check for keyboard CMP #3 ;event BNE GETMK2 LDA EVMSG ;Keyboard event, check AND #$7F ;for a match in MKData LDY #26 ;and set the BxPtr GETMK1 DEY ;accordingly DEY BMI GETMK4 CMP MKDATA,Y BNE GETMK1 LDA MKDATA1,Y STA BXPTR CLC ;Valid event, carry is RTS ;clear on return GETMK2 CMP #1 ;Check for mouse event BNE GETMK PEA 22 ;Mouse event, check if GETMK3 PLY ;it was inside a game DEY ;system or box and set DEY ;BxPtr accordingly BMI GETMK4 PHY PEA 0 PEA EVWHERE|-16 PEA EVWHERE PEA RECPTR|-16 LDA RECPTR,Y PHA LDX #$4F04 JSL $E10000 ;PtInRect PLA BEQ GETMK3 PLA STA BXPTR CLC ;Valid event, carry is RTS ;clear on return GETMK4 SEC ;Invalid event, carry RTS ;is set on return ***************************************************************** * FixPic - Redraws the screen if any changes were made * ***************************************************************** FIXPIC STA NEWPIC ;Save our new field EOR OLDPIC ;Note any changes from STA TRSHVAR ;old field in TrshVar PEA 18 ;Starting at system 9 FIXPIC1 PLY ;and working down DEY DEY BPL FIXPIC2 ;Done? PEA 14 ;Yes, pen = light grey LDX #$3704 JSL $E10000 ;SetSolidPenPat PEA MVREC|-16 ;Fill move count area PEA MVREC ;with light grey LDX #$5404 JSL $E10000 ;PaintRect LDA MOVES ;Change the move count PHA ;from an integer into PEA MOVES2|-16 ;an ASCII string PEA MOVES2 PEA 6 PEA 0 LDX #$260B JSL $E10000 ;Int2Dec PEA 147 ;Move pen to move count PEA 183 ;location LDX #$3A04 JSL $E10000 ;MoveTo PEA MOVES2|-16 ;Draw the last three PEA MOVES2+3 ;digits of the move count PEA 3 LDX #$A704 JSL $E10000 ;DrawText LDA NEWPIC STA OLDPIC RTS FIXPIC2 PHY LDA TRSHVAR ;Was there a change to AND STRPTS,Y ;the current system? BEQ FIXPIC1 ;No, next system AND NEWPIC ;Changed to star or hole? BEQ FIXPIC3 PEA 7 ;Star, pen = red LDX #$3704 JSL $E10000 ;SetSolidPenPat PLY ;Draw the star PHY PEA CPTRS|-16 LDA CPTRS,Y PHA LDX #$5904 JSL $E10000 ;PaintOval JMP FIXPIC1 FIXPIC3 PEA 1 ;Hole, pen = dark grey LDX #$3704 JSL $E10000 ;SetSolidPenPat PLY ;Draw hole's interior PHY PEA RECPTR|-16 LDA RECPTR,Y PHA LDX #$5404 JSL $E10000 ;PaintRect PEA 0 ;Pen = black LDX #$3704 JSL $E10000 ;SetSolidPenPat PLY ;Draw hole's outline PHY PEA RECPTR|-16 LDA RECPTR,Y PHA LDX #$5304 JSL $E10000 ;FrameRect PLY ;Draw space behind hole PHY PEA PTRS2|-16 LDA PTRS2,Y PHA LDX #$5404 JSL $E10000 ;PaintRect JMP FIXPIC1 ***************************************************************** * Bleep and Bloop - The sound routines * ***************************************************************** BLEEP LDY #$40 ;Bleep! BLEEP1 TYA ;Bleep and Bloop are TAX ;modified //e 'speaker BLEEP2 DEX ;peeker' routines for BNE BLEEP2 ;sound with various LDA $E0C030 ;time delays between LDX #$180 ;speaker clicks BLEEP3 DEX BNE BLEEP3 STA $E0C030 DEY BNE BLEEP1 RTS BLOOP LDY #$30 ;Bloop! BLOOP1 LDX #$110 BLOOP2 DEX BNE BLOOP2 LDA $E0C030 LDX #$110 BLOOP3 DEX BNE BLOOP3 STA $E0C030 DEY BNE BLOOP1 RTS ***************************************************************** * Speedy Message Delivery Service * ***************************************************************** MSG STA MSG2+1 ;Store message address PEA 4 ;Text mode = foreCOPY LDX #$9C04 JSL $E10000 ;SetTextMode PEA 4 ;Move cursor to top left LDA #9 ;X = 4 and Y = 9 STA TRSHVAR PHA LDX #$3A04 JSL $E10000 ;MoveTo PEA $FFFF MSG1 PLY ;Get message pointer INY ;Go to next character PHY MSG2 DC H'B90000' ;Equates to LDA XXXX,Y AND #$7F ;Keep bits 0 through 6 CMP #$1F ;Control character? BCC MSG3 ;Yes, handle it. PHA ;No, draw the character LDX #$A404 JSL $E10000 ;DrawChar BRA MSG1 MSG3 CMP #$10 ;Color change? BCS MSG4 PHA ;Yes, pen = current LDX #$A004 ;character's value JSL $E10000 ;SetForeColor BRA MSG1 MSG4 CMP #$11 ;New line? BNE MSG5 LDA TRSHVAR ;Yes, Y = Y plus 10 CLC ADC #10 STA TRSHVAR PEA 4 ;X = 4 PHA LDX #$3A04 JSL $E10000 ;MoveTo BRA MSG1 MSG5 CMP #$13 ;Line adjust? BNE MSG6 PEA 0 ;Yes, Y = Y plus 1 PEA 1 LDX #$3B04 JSL $E10000 ;Move INC TRSHVAR BRA MSG1 MSG6 CMP #$14 ;Venice font? BNE MSG7 LDA VENICEF+2 ;Yes, install PHA ;the new font LDA VENICEF PHA PEA 1 ;No scaling LDX #$0E1B JSL $E10000 ;InstallFont JSR ERRORS ;Check for errors CMP #$DE01 ;If we can't find venice BEQ MSG6 ;font on system disk, JMP MSG1 ;ignore the font change MSG7 CMP #$15 ;System font? BNE MSG8 LDX #$131B ;Yes, restore the font JSL $E10000 ;LoadSysFont JMP MSG1 MSG8 PLA ;Non-recognized control RTS ;characters = end msg ***************************************************************** * Errors handled here free of charge * ***************************************************************** ERRORS BCS ERRORS1 ;Did an error occur? RTS ;No, we're done ERRORS1 CMP #$45 ;Was it the wrong disk? BNE CRASH BEGDISK JSL $E100A8 ;GetBootVol DC I2'$28',I4'BVPARM' ;Get the boot disk for PHA ;tool set and font PEA 20 ;loading PEA 50 PEA PROMPT|-16 PEA PROMPT PEA VOLNAME|-16 PEA VOLNAME PEA OK_MSG|-16 PEA OK_MSG PEA CNCLMS|-16 PEA CNCLMS LDX #$1101 JSL $E10000 ;TLMountVolume PLA CMP #1 ;Is the right disk in? BNE NODISK LDA #$DE01 ;Yes, load 'Disk OK' RTS ;message and return NODISK LDA #$DE00 ;No, load 'Wrong Disk' RTS ;message and return CRASH PHA ;Major Malfunction, PEA CRSHDAT|-16 ;display error message PEA CRSHDAT ;and crash LDX #$1503 JSL $E10000 ;SysFailMgr ***************************************************************** * FIN - Shut down, quit, go home * ***************************************************************** FIN LDX #$031B ;Shut down the tools JSL $E10000 ;FMShutDown FIN1 LDX #$0306 JSL $E10000 ;EMShutDown LDX #$0304 JSL $E10000 ;QDShutDown LDX #$0303 JSL $E10000 ;MTShutDown LDA HANDLE+2 ;Give back our PHA ;DP memory space LDA HANDLE PHA LDX #$1002 JSL $E10000 ;DisposeHandle LDA USERID PHA LDX #$0302 JSL $E10000 ;MMShutDown LDX #$0301 JSL $E10000 ;TLShutDown JSL $E100A8 ;GSOS Quit DC I2'$29',I4'FINDATA' ***************************************************************** * Data Space - Where no man has gone before * ***************************************************************** USERID DS 2 HANDLE DS 4 DPAGES DS 2 BVPARM DC I4'VOLNAME' PROMPT DC H'0D',C'Please Insert' VOLNAME DS 18 OK_MSG DC I1'4',C'Okay' CNCLMS DC I1'5',C'Abort' CRSHDAT DC I1'55,13,10,10',11I1'32',C'Major Malfunction!' DC I1'13,10',14I1'32',C'Error: ' FINDATA DC 6H'00' COLORS DC H'0000440441082C070F008000700F000D' DC H'A90FF00FE000DF04AF0D8F07AA0AFF0F' VENICEF DC I4'$0E000005' BXPTR DS 2 TRSHVAR DS 2 EVREC ANOP EVWHAT DS 2 EVMSG DS 8 EVWHERE DS 6 MKDATA DC I'49,50,51,52,53,54,55,56,57,81,82,113,114' MKDATA1 DC I'0,2,4,6,8,10,12,14,16,18,20,18,20' OLDPIC DS 2 NEWPIC DS 2 MOVES DS 2 MOVES2 DS 6 STRPTS DC I'1,2,4,8,16,32,64,128,256' HITMODS DC H'1B00070036004900BA002401D800C001B001' RECPTR DC I'ORECS,ORECS+8,ORECS+16,ORECS+24,ORECS+32' DC I'ORECS+40,ORECS+48,ORECS+56,ORECS+64,QREC,RREC' PTRS2 DC I'IRECS,IRECS+8,IRECS+16,IRECS+24,IRECS+32' DC I'IRECS+40,IRECS+48,IRECS+56,IRECS+64' CPTRS DC I'STRS,STRS+8,STRS+16,STRS+24,STRS+32' DC I'STRS+40,STRS+48,STRS+56,STRS+64' TOPREC DC I'10,87,29,232' MIDREC DC I'40,87,160,232' BTMREC DC I'170,87,189,232' ORECS DC I'122,92,156,133,122,139,156,180,122,186,156,227' DC I'83,92,117,133,83,139,117,180,83,186,117,227' DC I'44,92,78,133,44,139,78,180,44,186,78,227' QREC DC I'172,89,187,146' RREC DC I'172,173,187,230' MVREC DC I'172,147,187,172' IRECS DC I'122,105,146,133,122,143,146,176,122,186,146,214' DC I'86,105,114,133,86,143,114,176,86,186,114,214' DC I'54,105,78,133,54,143,78,176,54,186,78,214' STRS DC I'124,102,148,131,124,145,148,174,124,188,148,217' DC I'88,102,112,131,88,145,112,174,88,188,112,217' DC I'52,102,76,131,52,145,76,174,52,188,76,217' GAMMSG DC H'1114',4H'13',24H'20',C'Teaser GS',16H'11',H'15' DC 24H'20',C'Quit',11H'20',C'Restart',H'16' WINMSG DC 7H'11',H'0414',19H'20',C'Congratulations!',2H'11' DC 21H'20',C'You''ve solved',2H'11',23H'20' DC C'the puzzle!',H'001516' LOSEMSG DC 8H'11',H'0414',27H'20',C'Sorry,',2H'11' DC 25H'20',C'You lost.',H'001516' HIMSG DC H'1114',23H'20',C'Teaser GS',H'151111',23H'20' DC H'01',C'By Timothy // Shay',H'111102' DC 19H'20',C'Copyright 1991 By',H'11' DC 19H'20',C'MindCraft Publ. Corp.' DC H'111104',9H'20',C'- Start -',10H'20',C'- Win -' DC 10H'20',C'- Lose -',H'1101',14H'20',C'789',17H'20' DC H'0737383901',17H'20',H'37383911',14H'20',H'3407' DC H'35013607',17H'20',H'340135073601',17H'20',C'456' DC H'11',14H'20',C'123',17H'20',H'0731323301',17H'20' DC C'123',H'111104',16H'20',C'- Moves -',16H'20' DC C'- Moves -',H'1101',3H'373839202020',H'03370138' DC H'3920202037033801392020203738033920202007370338' DC H'0139202020033707380339202020013703380739110334' DC H'3501362020203435362020203403353620202007340135' DC H'3620202003340735033620202001343507362020200334' DC H'3501362020203435362020203403353611073103320133' DC H'2020200331073203332020200131033207332020200331' DC H'01323320202031033201332020203132033301' DC 3H'202020313233',H'11110F202020',C'',H'001516' END